package com.guandata.cdc.model.sink;

import com.guandata.cdc.model.ConnectParam;
import com.guandata.cdc.model.DataTableType;
import lombok.Getter;
import lombok.NonNull;

import java.util.Map;
import java.util.Set;
import java.util.function.Function;

@Getter
public enum SinkConnectParam implements ConnectParam {
    PASSWORD(
    "password",
        Set.of(DataTableType.POSTGRES, DataTableType.GAUSS),
        params -> true
    ),
    TABLE_NAME(
    "table-name",
        Set.of(DataTableType.POSTGRES, DataTableType.GAUSS),
        params -> true
    ),
    URL(
    "url",
        Set.of(DataTableType.POSTGRES, DataTableType.GAUSS),
        params -> true
    ),
    USERNAME(
    "username",
        Set.of(DataTableType.POSTGRES, DataTableType.GAUSS),
        params -> true
    ),
    AUTO_FLUSH_BATCH_SIZE(
    "autoFlushBatchSize",
        Set.of(DataTableType.GAUSS),
        params -> true
    );

    private final String param;
    private final Function<Map<ConnectParam, String>, Boolean> preChecker;
    private final Set<DataTableType> dataTableTypes;

    SinkConnectParam(
        @NonNull String param,
        @NonNull Set<DataTableType> dataTableTypes,
        @NonNull Function<Map<ConnectParam, String>, Boolean> preChecker
    ) {
        this.param = param;
        this.dataTableTypes = dataTableTypes;
        this.preChecker = preChecker;
    }
}
